<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
				xmlns:ui="http://java.sun.com/jsf/facelets"
				xmlns:h="http://java.sun.com/jsf/html"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich"
				xmlns:f="http://java.sun.com/jsf/core"
				xmlns:c="http://java.sun.com/jstl/core"
				xmlns:t="http://myfaces.apache.org/tomahawk"
				template="/pages/crud_template.xhtml"> 

	<ui:param name="crudBean" value="#{matrizBean}" />
	
	<ui:define name="requiredFieldsMessage">
		<h:outputText value="#{bundle.todosCamposObrigatorios}" rendered="#{crudBean.updating}"/>
	</ui:define>

     <ui:define name="saveStateObjectsDefined">
		<t:saveState value="#{crudBean.listaMatriz}" />
	</ui:define>

	<ui:define name="buttonItens">
		<!-- Painel dos botoes de pesquisa -->
		<h:panelGroup rendered="#{crudBean.updating}">
		</h:panelGroup>
	</ui:define>
		
	<ui:define name="content">
		<!-- Painel de Cadastro - Inicio -->
		<h:panelGroup id="panelGroupDeCadastro" rendered="#{crudBean.updating}">
			<f:subview id="viewCadastro">
				<table>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_empresa}"/> </td>
						<td class="tdBranco">
							<h:outputText value="#{crudBean.entity.empresaVo.codigo}" />
							<h:outputText value=" - " />
							<h:outputText value="#{crudBean.entity.empresaVo.descricao}" />
						</td>
					</tr>
					<tr>
						<td class="tdCor"><h:outputText value="#{bundle.lbl_descricao}"/> *</td>
						<td class="tdBranco">
							<h:inputText value="#{crudBean.entity.descricao}" size="80" maxlength="50" onkeypress="return maiuscula(this)" />
						</td>
					</tr>
				</table>

				<br></br>
				
				<table>
					<tr>
						<td>
							<a4j:commandButton value="#{bundle.lbl_add}" actionListener="#{crudBean.adicionar}" reRender="panelGroupDeCadastro"/>
							<h:outputText value=" "/>
							<t:commandButton value="#{bundle.lbl_voltar}" action="#{empresaBean.preparaPesquisar}"></t:commandButton>
						</td>
					</tr>
				</table>
				
				<br></br>
				<br></br>
				
				<f:subview id="viewMatriz">
					<rich:dataTable id="tblData" value="#{crudBean.listaMatriz}" binding="#{crudBean.tblData}" var="rst" style="width: 50%;" rowClasses="par,impar">
						
						<rich:column style="text-align: right;" sortBy="#{rst.codigo}">
							<f:facet name="header">
								<h:outputText value="#{bundle.lbl_codigo}" />
							</f:facet>
							<h:outputText value="#{rst.codigo}"/>
						</rich:column>
	               		<rich:column style="text-align: left;" sortBy="#{rst.descricao}">
							<f:facet name="header">
								<h:outputText value="#{bundle.lbl_nome}" />
							</f:facet>
							<h:outputText value="#{rst.descricao}"/>
						</rich:column>
	               		<rich:column style="text-align: center;" sortBy="#{rst.situacao}">
							<f:facet name="header">
								<h:outputText value="#{bundle.lbl_situacao}" />
							</f:facet>
							<h:outputText value="#{rst.situacao}"/>
						</rich:column>
	               		<rich:column style="text-align: center;">
							<f:facet name="header">
								<h:outputText value="" />
							</f:facet>
							<a4j:commandLink actionListener="#{crudBean.excluir}" rendered="#{rst.situacao == 'SIM' }" ajaxSingle="true" reRender="tblData">
								<h:graphicImage title="cancelar" value="/imagens/inativar.bmp" style="border: 0px;"/>
							</a4j:commandLink>
						</rich:column>
					</rich:dataTable>
				</f:subview>
				
			</f:subview>
		</h:panelGroup>
		<!-- Painel de Cadastro - Fim -->
		
	</ui:define>
	
</ui:composition>